import java.util.Scanner;

import javax.swing.JOptionPane;

public class Challenge5
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		String userSelection = "";
		
		
		String numStr1 = JOptionPane.showInputDialog(null, "Choose First Number: ");
		double num1 = Double.parseDouble(numStr1);
		
		while (!userSelection.equals("Q") && !userSelection.equals("q"))
		{
			
			userSelection = JOptionPane.showInputDialog(null, "------------------------\n" +
					"Choose an operator.\n" +
					"+\n" +
					"-\n" +
					"*\n" +
					"/\n" +
					"(Q)uit");
			
			switch (userSelection)
			{
				case "+":
					JOptionPane.showMessageDialog(null, "You have selected ADD!");
					String numStr2 = JOptionPane.showInputDialog(null, "Choose Second Number: ");
					double num2 = Double.parseDouble(numStr2);
					JOptionPane.showMessageDialog(null, num1 + " + " + num2 + " = " + (num1 + num2));
					num1 = num1 + num2;
					
					break;
				case "-":
					JOptionPane.showMessageDialog(null, "You have selected SUBTRACT!");
					String numStr3 = JOptionPane.showInputDialog(null, "Choose Second Number: ");
					double num3 = Double.parseDouble(numStr3);
					JOptionPane.showMessageDialog(null, num1 + " - " + num3 + " = " + (num1 - num3));
					num1 = num1 - num3;
					break;
				case "*":
					JOptionPane.showMessageDialog(null, "You have selected MULTIPLY!");
					String numStr4 = JOptionPane.showInputDialog(null, "Choose Second Number: ");
					double num4 = Double.parseDouble(numStr4);
					JOptionPane.showMessageDialog(null, num1 + " * " + num4 + " = " + (num1 * num4));
					num1 = num1 * num4;
					break;
				case "/":
					JOptionPane.showMessageDialog(null, "You have selected DIVIDE!");
					String numStr5 = JOptionPane.showInputDialog(null, "Choose Second Number: ");
					double num5 = Double.parseDouble(numStr5);
					JOptionPane.showMessageDialog(null, num1 + " / " + num5 + " = " + (num1 / num5));
					num1 = num1 / num5;
					break;
				default:
					JOptionPane.showMessageDialog(null,"Invalid selection!");
					break;
				case "Q":
				case "q":
					JOptionPane.showMessageDialog(null, "You have QUIT!");
			}
		}
	}
}
